
import player
import random

class RandomPlayer(player.Player):

    def do_move(self, game_state, player_idx, stone_list):
        move = {}
        #select stone to put in pandoras box:
        if stone_list["black"] == 0:
            move["stone"] = "white"
        elif stone_list["white"] == 0:
            move["stone"] = "black"
        else:
            if random.randint(0, 1) == 0:
                move["stone"] = "white"
            else:
                move["stone"] = "black"

        #to swap or not (TODO: change propability?):
        if random.randint(0, 1) == 0:
            while True:
                player_to_swap_with = random.randint(0, len(game_state.get_player_list()) - 1)
                if not player_to_swap_with == player_idx:
                    move["swap"] = player_to_swap_with
                    break
        else:
            move["swap"] = -1

        game_state.finish_move(move)


    def get_type_name(self):
        return "(AI) Random"
